home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / oath.lha / oath / test / pdl2b.cc < prev    next >
C/C++ Source or Header  |  1991-08-29  |  2KB  |  73 lines

  1. #include "oath/pdlQueue.h"
  2.  
  3. #include "oath/character.h"
  4.  
  5. #include <fstream.h>
  6.  
  7. /////////////////////////////////////////////////////////////////////////////
  8. // Test of pdlQueues and putCopy()/getCopy()
  9.  
  10. main ()
  11.    {// Predefine Four Characters //////////
  12.     characterA A = characterA::make('A');
  13.     characterA B = characterA::make('B');
  14.     characterA C = characterA::make('C');
  15.     characterA D = characterA::make('D');
  16.  
  17.     cout << A << B << C << D << endl;
  18.  
  19.     // Retrieve the Three Lists //////////
  20.     ifstream File ("pdl2.obj");
  21.  
  22.     pdlQueueA L1 = pdlQueueA::isa(objA::import(File));
  23.     pdlQueueA L2 = pdlQueueA::isa(objA::import(File));
  24.     pdlQueueA L3 = pdlQueueA::isa(objA::import(File));
  25.  
  26.     // Test Code //////////
  27.     if(L1.is(L2) || L1.is(L3))
  28.         cout << "is() failed!" << endl;
  29.     else
  30.         cout << "is() succeeded!" << endl;
  31.  
  32.     if(L1 == L2 && L1 == L3)
  33.         cout << "== succeeded!" << endl;
  34.     else
  35.         cout << "== failed!" << endl;
  36.  
  37.     if(L1.isEmpty() || L2.isEmpty() || L3.isEmpty())
  38.         cout << "isEmpty() failed!" << endl;
  39.     else
  40.         cout << "isEmpty() succeeded!" << endl;
  41.  
  42.     if(L1.contains(A) && L1.contains(B) && !L1.contains(D))
  43.         cout << "contains() succeeded!" << endl;
  44.     else
  45.         cout << "contains() failed!" << endl;
  46.  
  47.     cout << "There are " << L1.count() << " characters in L1: ";
  48.     posA P1 = L1.makePos();
  49.     while(P1())
  50.        {cout << characterA::isa(*P1);
  51.     ++P1;
  52.        }
  53.     cout << endl;
  54.  
  55.     cout << "The second character is " << characterA::isa(L1[1]) << endl;
  56.  
  57.     objA O;
  58.     L2 >> O;
  59.     cout << "The first character removed is " 
  60.      << characterA::isa(O) << endl;
  61.  
  62.     cout << "There are " << L2.count() << " characters in L2: ";
  63.     posA P2 = L2.makePos();
  64.     while(P2())
  65.        {cout << characterA::isa(*P2);
  66.         ++P2;
  67.        }
  68.     cout << endl;
  69.  
  70.    }
  71.  
  72.  
  73.